package com.zx.kitchen.index.common.mvp.model;

import android.app.ProgressDialog;
import android.content.Context;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.loopj.android.http.RequestParams;
import com.zx.kitchen.index.common.base.Contants;
import com.zx.kitchen.index.common.entity.PurchaseData;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.utils.HttpUtils;
import com.zx.kitchen.index.common.utils.PreferenceUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/3/3.
 */

public class PurchaseModelImpl implements PurchaseModel {
    @Override
    public void getFromNet(int requestCode, Context context, int p, String start_time, String end_time,
                           OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("user_data", PreferenceUtil.getStringData(context, Contants.spToken));
        params.put("p", p);
        params.put("start_time", start_time);
        params.put("end_time", end_time);
        HttpUtils.post(context, Contants.PURCHASE_URL, params, requestCode, listener, progressDialog);
    }

    @Override
    public PurchaseData asyncJson(String str) {
        return JSON.parseObject(str, new TypeReference<PurchaseData>() {
        });
    }
}
